﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace NinjaToolbox
{
    public class TimeSlowerManager_Example : MonoBehaviour
    {
        public float debug_CurrentTimeScale;
        TimeSlowerManager.TimeScaleHandler mHandler1;
        TimeSlowerManager.TimeScaleHandler mHandler2;


        void Awake()
        {
            mHandler1 = TimeSlowerManager.Instance.RegistTimeScaleHandler();
            mHandler2 = TimeSlowerManager.Instance.RegistTimeScaleHandler();
        }

        void Update()
        {
            transform.position = Vector3.right * Mathf.Sin(Time.time * 10) * 10f;

            debug_CurrentTimeScale = Time.timeScale;
        }

        void OnDestroy()
        {
            TimeSlowerManager.Instance.UnregistTimeScaleHandler(mHandler1);
            TimeSlowerManager.Instance.UnregistTimeScaleHandler(mHandler2);
        }

        [ContextMenu("Handler1 Slow 0.23x")]
        void Handler1_Slow023()
        {
            mHandler1.ExpectTimeScale = 0.23f;
        }

        [ContextMenu("Handler1 Slow 1x")]
        void Handler1_Slow1()
        {
            mHandler1.ExpectTimeScale = 1f;
        }

        [ContextMenu("Handler2 Slow 0.25x")]
        void Handler2_Slow025()
        {
            mHandler2.ExpectTimeScale = 0.25f;
        }

        [ContextMenu("Handler2 Slow 1x")]
        void Handler2_Slow1()
        {
            mHandler2.ExpectTimeScale = 1f;
        }
    }
}
